package com.zzx.controller;

import com.zzx.service.OrderService;
import com.zzx.util.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/orders")
public class OrderController {

    @Autowired
    private OrderService orderService;

    /**
     * 获取订单列表
     * @param query
     * @param pagenum
     * @param pagesize
     * @return
     */
    @GetMapping
    @PreAuthorize("hasAuthority('订单列表')")
    public ResponseResult getOrderList(@RequestParam(required = false) String query,Integer pagenum,Integer pagesize){
        return orderService.getOrderList(query,pagenum,pagesize);
    }

    /**
     * 通过id修改订单状态
     * @param id
     * @return
     */
    @PreAuthorize("hasAuthority('订单更新')")
    @PutMapping("/{id}")
    public ResponseResult getOrderById(@PathVariable("id")Long id){
        return orderService.getOrderById(id);
    }

}
